package my.georings.dialog;

import my.georings.R;
import android.app.Dialog;
import android.content.Context;
import android.widget.SeekBar;
import android.widget.TextView;;

public class VolumeDialog extends Dialog implements SeekBar.OnSeekBarChangeListener{

	
	private int volume;
	
	
	public VolumeDialog(Context context, int volume) {
		super(context);
		setContentView(R.layout.volumeget);
        setTitle("Choose volume");
        
        SeekBar volControl = (SeekBar)findViewById(R.id.volumeget_seek);
        
        if(volume >= 0){
        	volControl.setProgress(volume);
        	this.volume = volume;
        }else
        	this.volume = 0;
        
        volControl.setOnSeekBarChangeListener(this); 
	}

	@Override
	public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
		this.volume = progress;
		((TextView)findViewById(R.id.volumeget_text)).setText(volume*10+"%");
	}

	@Override
	public void onStartTrackingTouch(SeekBar seekBar) {
	}

	@Override
	public void onStopTrackingTouch(SeekBar seekBar) {
	}
	
	
	public int getVolume() {
		return volume;
	}

	public void setVolume(int volume){
		((SeekBar)findViewById(R.id.volumeget_seek)).setProgress(volume >= 0 ?  volume : 0);
	}


}
